package com.ttg.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.*;

/**
 * 性别（0未知，1男，2女）
 *
 * @author h
 * @date 2023/07/05 14:52:11
 **/
public enum VipSexEnum {


    /**
     * 未知
     */
    UNKNOWN(0, "未知"),
    /**
     * 渠道
     */
    MAN(1, "男"),
    /**
     * 女
     */
    WOMAN(2, "女");

    @JsonValue
    private Integer value;
    private String desc;

    VipSexEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, VipSexEnum> VALUES = new HashMap<>();

    static {
        for (final VipSexEnum type : VipSexEnum.values()) {
            VipSexEnum.VALUES.put(type.getValue(), type);
        }
    }

    public static List<String> VipSexEnum(){
        return new ArrayList<String>(Arrays.asList(
                VipSexEnum.MAN.getDesc(),
                VipSexEnum.WOMAN.getDesc()
        ));
    }

    @JsonCreator
    public static VipSexEnum of(Integer code) {
        return VipSexEnum.VALUES.get(code);
    }

    @JsonCreator
    public static VipSexEnum ofDesc(String desc) {
        for (VipSexEnum value : values()) {
            if (value.getDesc().equals(desc)){
                return value;
            }
        }
        return null;
    }
}
